﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>


<?php

include("inc/joomlaInt.php");
include("inc/inc_teamtausch.php");
include("inc/inc_bestaetigungen.php");
include("inc/inc_configuration.php");

  ini_set( 'display_errors', false );
  // error_reporting( E_ALL );


if ($jUser==0)
{
	echo "Bitte zuerst einloggen!";
}
else
{

	echo "<h1>$ligatitel</h1>";
	
	$t1Id=0;
	$t2Id=0;
	
	$cQ = "SELECT teamId,name,rating FROM $tbl_combinations c, $tbl_teams t WHERE c.userId=$jUser AND c.active=1 AND c.teamId=t.id";
	$cQe = mysql_query($cQ);
	$canz = mySQL_num_rows($cQe);
	
	$af_t_vh="	SELECT l.Id AS leagueId,  t.id AS teamId, t.rating AS rating, t.name AS name, c.id AS cId  
			FROM $tbl_combinations c, $tbl_teams t, $tbl_leagues l, $tbl_season s, $tbl_lt lt 
			WHERE 	c.userID=$jUser AND 
					c.active=1 AND 
					c.teamId=t.id AND
					s.active=1 AND
					l.seasonId=s.id AND
					lt.teamId=t.id AND
					lt.leagueId=l.id AND
					l.type=1"; //vorhandene Teams suchen
	$e_t_vh = mysql_query($af_t_vh);
	$count = mySQL_num_rows($e_t_vh);
	
	
	
	
	
	if ($count>=1)
	{
		$o=mysql_fetch_object($e_t_vh);
		$t1i=$o->teamId;
		$t1r=$o->rating;
		$t1l=$o->leagueId;
		$t1n=$o->name;
		$t1c=$o->cId;
		
		echo "Sie sind aktuell Trainer bei : <a class='tooltip'><img src='img/logos/$t1i.png' width='35' height='35'><span>$t1n</span></a>";
	
		if ($count>=2)
		{
			$o=mysql_fetch_object($e_t_vh);
			$t2i=$o->teamId;
			$t2r=$o->rating;
			$t2l=$o->leagueId;
			$t2n=$o->name;
			$t2c=$o->cId;
			
			echo " <a class='tooltip'><img src='img/logos/$t2i.png' width='35' height='35'><span>$t2n</span></a>";
		}
		
		if ($count==3)
		{
			$o=mysql_fetch_object($e_t_vh);
			$t3i=$o->teamId;
			$t3r=$o->rating;
			$t3l=$o->leagueId;
			$t3n=$o->name;
			$t3c=$o->cId;
			
			echo " <a class='tooltip'><img src='img/logos/$t3i.png' width='35' height='35'><span>$t3n</span></a>";
		}

	// if ($canz>0)
	// {
		// $t1nO=mysql_fetch_object($cQe);
		// $t1n=$t1nO->name;
		// $t1i=$t1nO->teamId;
		// $t1r=$t1nO->rating;
		
		// echo "Sie sind aktuell Trainer bei : <a class='tooltip'><img src='img/logos/$t1i.png' width='35' height='35'><span>$t1n</span></a>";
		
		// if ($canz==2)
		// {
			// $t2nO=mysql_fetch_object($cQe);
			// $t2n=$t2nO->name;
			// $t2i=$t2nO->teamId;
			// $t2r=$t2nO->rating;
			
			// echo " <a class='tooltip'><img src='img/logos/$t2i.png' width='35' height='35'><span>$t2n</span></a>";
		// }
		
		$a=get_anzahl_bestaetigungen($jUser);
					
		if ($a>0)
		{
			echo "<b><a href='spiel_bestaetigen.php' class='notificationB notification'>Unbestätigte Spiele!</a></b>";
		}
		
		$rating=$t1r+$t2r;
		
		if (($ttb==1) && ($rating>$maxrating))
		{
			echo "<b><a href='#' class='notificationB notification'>Du überschreitest 8*!</a></b>";
		}
		
		if (($ttb==1) && ($t1l == $t2l))
		{
			echo "<b><a href='#' class='notificationB notification'>Teams in gleicher Liga!</a></b>";
		}
	
		echo "<a href='profil.php?id=$jUser' class='button profil'>Mein Profil</a>";
		
		$te=get_teamtausch_erlaubt($jUser);

		if ($te==1)
		{
			echo "<a href='teamtausch.php' class='button teamtausch'>Teamtausch</a>";
		}
		
		if ($ttb>=1)
		{
			echo "<a href='boerse.php' class='button teamtauschboerse'>Teamtauschbörse</a>";
		}
		
		echo "<a href='kuendigen.php' class='button kuendigen'>Kündigen</a>";		
	}
	else
	{
		echo "Sie haben noch kein Team!";
		
		$a=get_anzahl_bestaetigungen($jUser);
					
		if ($a>0)
		{
			echo "<b><a href='spiel_bestaetigen.php' class='notificationB notification'>Unbestätigte Spiele!</a></b>";
		}
		
		echo "<a href='profil.php?id=$jUser' class='button profil'>Mein Profil</a>";
	}
	
	
	
	if ($canz<2)
	{
		echo "<a href='teamwahl.php' class='button teamwahl'>Teamwahl</a>";
	}
	
	if ($canz>0)
	{
		echo "<a href='meine_spiele.php' class='button spiele'>Meine Spiele</a>";
	}
	
	echo "<a href='abwesenheit.php' class='button abwesenheit'>Abwesenheit</a>";
	
	
	echo "			<a href='teamhistory.php' class='button history'>Team History</a>";
					
					
					echo "
							<a href='trainerwechsel.php' class='button trainerwechsel'>Trainerwechsel</a>
							";
					
					$q="SELECT gid FROM $tbl_users WHERE id=$jUser";
					$qe=mysql_query($q);
					$qeo=mysql_fetch_object($qe);
					
					$gid=$qeo->gid;
					
					if ($gid==$admingroup)
					{
						include ("admin.php");
					}
					
					if ($debug==1)
					{
						include ("debug.php");
					}
}

?>

</body>
</html>